Repository navigation
Preserve Ghostscript diagnostics when stderr is not UTF-8 - #1421
Open
hyperammonemia wants to merge 2 commits into
Open
hyperammonemia wants to merge 2 commits into
hyperammonemia wants to merge 2 commits into
Conversation
Decode failed-repair diagnostics with replacement and cover invalid bytes, valid UTF-8, and the successful output path. Prepared with OpenAI Codex assistance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When Ghostscript exits with a nonzero status and writes a non-UTF-8 byte to stderr,
_repairraisesUnicodeDecodeErrorwhile decoding the diagnostic. This hides Ghostscript's readable error message.Decode stderr with
errors="replace"so the existingExceptioncontains that message, with invalid byte sequences replaced by U+FFFD. Valid UTF-8 remains intact. The tests cover both encodings on failure and confirm that a successful repair still returns its PDF bytes when stderr contains a non-UTF-8 warning.Related to #1145, which reports a similar UnicodeDecodeError when using
repair=True. The PDF from that issue is unavailable, so these tests reproduce the failure path with mocked Ghostscript output; they do not reproduce or resolve the underlying PDF repair failure.Validation:
beeecc16240d5855c866a697ab210796ad887080.AI assistance: OpenAI Codex prepared the code, tests, and this description and executed the validation. No human review is claimed.